package com.tepusoft.weixin.service;

import com.tepusoft.weixin.dao.UserDao;
import com.tepusoft.weixin.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * User: GIE
 * Date: 2015/12/14
 * description：
 */
@Service
public class UserService {
	@Autowired
	private UserDao userDao;

	public void saveUser(User user) {
		userDao.save(user);
	}

	public List<User> findAll() {
		Iterable<User> iterable =  userDao.findAll();
		Iterator<User> iterator = iterable.iterator();
		List<User> list = new ArrayList<User>();
		while (iterator.hasNext()){
			list.add(iterator.next());
		}
		return list;
	}
}
